package com.zto.sch.beanpostprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.core.PriorityOrdered;

/**
 * @program: javatest
 * @description:
 * @author: sch
 * @create: 2020-09-08 22:28
 **/
//@Component
public class TestBeanPostProcessor2 implements BeanPostProcessor, PriorityOrdered {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("userDao")) {
            System.out.println("postProcessBefore2...");
        }
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        if (beanName.equals("userDao")) {
            System.out.println("postProcessAfter2...");
        }
        return bean;
    }

    /**
     * 值越小越先执行
     *
     * @return
     */
    @Override
    public int getOrder() {
        return 8;
    }
}
